﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// enterprise_level
	/// </summary>
	public partial class enterprise_level
	{
		private readonly lcmyjobs.DAL.enterprise_level dal=new lcmyjobs.DAL.enterprise_level();
		public enterprise_level()
		{}
          /// <summary>
        /// 升级会员
        /// </summary>
        /// <param name="enterprise_lid"></param>
        /// <param name="checktime">更改审核通过时间</param>
        /// <param name="status">更改状态为1 通过</param>
        /// <returns></returns>
        public int UpdateLevel(int enterprise_lid, DateTime checktime, int status)
        {
            return dal.UpdateLevel(enterprise_lid,checktime,status);
        }
         /// <summary>
        /// 获取单位升级信息
        /// </summary>
        /// <param name="atid"></param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetLevelInfo(int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetLevelInfo(atid, currentPageIndex, pageSize, out count);
        }
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int enterprise_lid)
		{
			return dal.Exists(enterprise_lid);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.enterprise_level model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.enterprise_level model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int enterprise_lid)
		{
			
			return dal.Delete(enterprise_lid);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string enterprise_lidlist )
		{
			return dal.DeleteList(enterprise_lidlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.enterprise_level GetModel(int enterprise_lid)
		{
			
			return dal.GetModel(enterprise_lid);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.enterprise_level GetModelByCache(int enterprise_lid)
		{
			
			string CacheKey = "enterprise_levelModel-" + enterprise_lid;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(enterprise_lid);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.enterprise_level)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_level> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_level> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.enterprise_level> modelList = new List<lcmyjobs.Model.enterprise_level>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.enterprise_level model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.enterprise_level();
					if(dt.Rows[n]["enterprise_lid"]!=null && dt.Rows[n]["enterprise_lid"].ToString()!="")
					{
						model.enterprise_lid=int.Parse(dt.Rows[n]["enterprise_lid"].ToString());
					}
					if(dt.Rows[n]["enterprise_bid"]!=null && dt.Rows[n]["enterprise_bid"].ToString()!="")
					{
						model.enterprise_bid=int.Parse(dt.Rows[n]["enterprise_bid"].ToString());
					}
					if(dt.Rows[n]["enterprise_mid"]!=null && dt.Rows[n]["enterprise_mid"].ToString()!="")
					{
						model.enterprise_mid=int.Parse(dt.Rows[n]["enterprise_mid"].ToString());
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

        /// <summary>
        /// 获得单位升级级别，状态
        /// </summary>
        public DataSet GetLevelById(int enterprise_bid)
        {
            return dal.GetLevelById(enterprise_bid);
        }
		#endregion  Method
	}

}

